package lab_09.task3.com.acme.bankapp.service.bank;

import lab_09.task3.com.acme.bankapp.domain.bank.Bank;
import lab_09.task3.com.acme.bankapp.domain.bank.Client;
import lab_09.task3.com.acme.bankapp.domain.bank.Gender;

public class BankApplication {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Bank bank = new Bank();
		BankService.addClient(bank,Gender.FEMALE, "Marina", 2);
		BankService.addClient(bank,Gender.MALE, "Oleg", 0);
		BankService.addClient(bank,Gender.MALE, "Ivan", 5);
		
		modifyBank(bank);
		printBalance(bank);
	}
	
	protected static void modifyBank(Bank bank) {
		for (Client client: bank.getClients()) {
			client.getClientAccount().deposit(0.5); //add 0.5 to each client
			client.getClientAccount().withdraw(0.25); //take 0.25 from each client's account	
		}
	}
	
	protected static void printBalance(Bank bank) {
		int i = 0;
		for (Client client: bank.getClients()) {
			System.out.format("Client number %1$d %2$s %3$s has %4$f on his account.\n", 
					i,
					client.getClientSalutation(),
					client.getClientName(),
					client.getClientAccount().getBalance()
					);
			i++;
		}
	}

}
